import sys
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QLineEdit
import styles.styles_elements as styles
from user_interface.ClassUserInterface import LineEdit


class CurveCirclePipeWidget(QWidget):
    def __init__(self, parent=None):
        super(CurveCirclePipeWidget, self).__init__(parent)

        self.layout = QVBoxLayout(self)

        self.element_parameters = QLabel("Параметры элемента", self)
        self.element_parameters.setObjectName('heading')
        self.element_parameters.setStyleSheet(styles.QLable_StyleSheet)

        self.element_parameters.setMaximumSize(16777215, 40)
        self.layout.addWidget(self.element_parameters)

        self.roughness = QLineEdit(self)
        self.roughness.setObjectName("roughness")
        self.roughness.setStyleSheet(styles.QLineEdit_StyleSheet)
        self.roughness.setPlaceholderText("шероховатость[мкм]")
        self.layout.addWidget(self.roughness)

        self.bend_radius = LineEdit(self)
        self.bend_radius.setObjectName("bend_radius")
        self.bend_radius.setStyleSheet(styles.QLineEdit_StyleSheet)
        self.bend_radius.setPlaceholderText("радиус гиба [м]")
        self.layout.addWidget(self.bend_radius)

        self.angle = LineEdit(self)
        self.angle.setObjectName("angle")
        self.angle.setStyleSheet(styles.QLineEdit_StyleSheet)
        self.angle.setPlaceholderText("угол [град]")
        self.layout.addWidget(self.angle)

        self.diameter = LineEdit(self)
        self.diameter.setObjectName("diameter")
        self.diameter.setStyleSheet(styles.QLineEdit_StyleSheet)
        self.diameter.setPlaceholderText("диаметр [м]")
        self.layout.addWidget(self.diameter)

        self.setLayout(self.layout)

    def get_params_element(self):
        return {self.roughness: self.roughness.text(),
                self.bend_radius: self.bend_radius.text(),
                self.angle: self.angle.text(),
                self.diameter: self.diameter.text(),
                }

    def get_name_params_element(self):
        return {self.roughness.objectName(): self.roughness.text(),
                self.angle.objectName(): self.angle.text(),
                self.diameter.objectName(): self.diameter.text(),
                self.bend_radius.objectName(): str(round(float(self.bend_radius.text().replace(',', '.')) /
                                                         float(self.diameter.text().replace(',', '.')), 2))
                }


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = CurveCirclePipeWidget()
    window.show()
    sys.exit(app.exec())
